<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/regsiter.css">

    <link rel="stylesheet" href="imgs/font/iconfont.css">
    <link rel="stylesheet" href="imgs/font1/iconfont.css">
    <!-- <link rel="stylesheet" href="./libs/bootstrap.css"> -->
    <script src="./libs/jquery.js"></script>
</head>

<body>
    <div id="top">

    </div>

    <div id="header">
        <h1 class="logo">
            <img src="./imgs/logo.png" alt="">
            <span><a href="">新品推荐</a></span>
            <span><a href="">热卖榜单</a></span>
        </h1>

    </div>


    strength-b
    <!-- 注册 -->
    <div class="loginbar">
        <div class="loginbar-a ">
            <div class="loginbar-b">
                <h2>手机号注册</h2>
                <div class="loginba-inp">
                    <div class="loginba-tel">
                        <i class="iconfont">&#xe9c9;</i>

                        <input type="text" name="" placeholder="手机号" id="tel"><span></span>

                    </div>
                    <!-- <div class="loginba-verification">
                 <i class="iconfont">&#xe64e;</i>
                    <input type="text" name="" id="left" placeholder="验证码">
                    <input type="text" name="" id="right">
                    <button>换一张</button>
                </div> -->
                    <!-- <div class="loginba-message">
                  <i class="iconfont">&#xe619;</i>
                    <input type="text" name="" id="loginba-message-left" placeholder="短信验证码">
                     <input type="submit" name="" id="loginba-message-right" value="获取验证码">
                </div> -->
                    <div class="loginba-password">
                        <i class="iconfont">&#xe6e6;</i>
                        <input type="password" name="" id="txt" placeholder="设置密码 "><span></span>
                    </div>



                    <div class="strength">
                        <ul class="strength-a">
                            <li class="strength-b">弱</li>
                            <li class="strength-c">中</li>
                            <li class="strength-d">强</li>
                        </ul>
                    </div>
                    <div class="loginba-password">
                        <i class="iconfont">&#xe6e6;</i>
                        <input type="password" name="" id="txets" placeholder="确认密码 "><span></span>
                    </div>







                    <div class="clause">
                        <span class="clause-b">
                            <label for=""><input type="checkbox"></label><span>阅读并同意</span><span><a
                                    href="">《优享用户服务条款》</a> </span><span>和</span><span><a href="">《优享用户隐私政策》</a> </span>
                        </span>
                    </div>
                    <input type="button" name="" id="regsiter" value="注册">
                    <div class="loginba">
                        <span>已有账号，</span><span><a href="./loginba.html">直接登录</a></span>
                    </div>

                </div>


            </div>

        </div>
    </div>



    <!-- 底部     -->
    <div class="mod-footer">

    </div>
</body>
<script src="js/ajax.js"></script> 
<script src="./js/jquery.js"></script>
<script>
    $("#top").load("http://localhost:3000/public/top.html .topCont")

    $(".mod-footer").load("http://localhost:3000/public/top.html .bottomCont")
</script>
<script>
    
    $("#regsiter").click(function(){
        // 收集用户输入的信息，通过ajax发往后端，等待返回信息
        $.ajax({
            url:"http://localhost:3000/api",
            data:{
                type:"register",
                username:$("#tel").val(),
                password:$("#password").val()
            },
            success:res=>{
                // 解析后端返回的信息，判断注册成功或是失败
                res = JSON.parse(res)
                console.log(res);
                if(res.code === 1){
                    // 注册成功的处理
                    if(confirm("注册成功，是否跳转到登录")){
                        // location.assign("./login.html")
                        location.href = "./login.html";
                    }
                }else if(res.code === 0){
                    // 注册失败的处理
                    alert(res.title + "，注册失败");
                }
            }
        })
    })
    
</script>
</script>
</html>